<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content=
    "application/xhtml+xml; charset=iso-8859-1" />
    <title>
      Tuning Fontconfig
    </title>
    <link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
    "text/css" media="print" />
  </head>
  <body class="blfs" id="blfs-2020-04-02">
    <div class="navheader">
      <h4>
        Beyond Linux<sup>�</sup> From Scratch <span class="phrase">(System
        V</span> Edition) - Version 2020-04-02
      </h4>
      <h3>
        Chapter&nbsp;24.&nbsp;X Window System Environment
      </h3>
      <ul>
        <li class="prev">
          <a accesskey="p" href="xorg-config.html" title=
          "Xorg-7 Testing and Configuration">Prev</a>
          <p>
            Xorg-7 Testing and Configuration
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="TTF-and-OTF-fonts.html" title=
          "TTF and OTF fonts">Next</a>
          <p>
            TTF and OTF fonts
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="installing.html" title=
          "Chapter&nbsp;24.&nbsp;X Window System Environment">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <h1 class="sect1">
        <a id="tuning-fontconfig" name="tuning-fontconfig"></a>Tuning
        Fontconfig
      </h1>
      <div class="sect2" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="fontconfig-overview" name="fontconfig-overview"></a>Overview
          of Fontconfig
        </h2>
        <p>
          If you only read text in English, and are happy with the common
          libre fonts listed on the next page, you may never need to worry
          about the details of how <span class=
          "application">fontconfig</span> works. But there are many things
          which can be altered if they do not suit your needs.
        </p>
        <p>
          Although this page is long, it barely scratches the surface and you
          will be able to find many alternative views on the web (but please
          remember that some things have changed over the years, for example
          the autohinter is no longer the default). The aim here is to give
          you enough information to understand the changes you are making.
        </p>
        <p class="usernotes">
          User Notes: <a class="ulink" href=
          "http://wiki.linuxfromscratch.org/blfs/wiki/Fontconfig">http://wiki.linuxfromscratch.org/blfs/wiki/Fontconfig</a>
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="xft-font-protocol" name="xft-font-protocol"></a>The Xft Font
          Protocol
        </h2>
        <p>
          The Xft font protocol provides antialiased font rendering through
          <span class="application">freetype</span>, and fonts are controlled
          from the client side using <span class=
          "application">fontconfig</span> (except for <a class="xref" href=
          "../xsoft/rxvt-unicode.html" title=
          "rxvt-unicode-9.22">rxvt-unicode-9.22</a> which can use fonts
          listed in <code class="filename">~/.Xresources</code>, and
          <a class="xref" href="../xsoft/AbiWord.html" title=
          "AbiWord-3.0.4">AbiWord-3.0.4</a> which only uses the specified
          font). The default search path is <code class=
          "filename">/usr/share/fonts</code> and <code class=
          "filename">~/.local/share/fonts</code> although for the moment the
          old and deprecated location <code class="filename">~/.fonts</code>
          still works. <span class="application">Fontconfig</span> searches
          directories in its path recursively and maintains a cache of the
          font characteristics in each directory. If the cache appears to be
          out of date, it is ignored, and information is fetched from the
          fonts themselves (that can take a few seconds if you installed a
          lot of fonts).
        </p>
        <p>
          If you've installed <span class="application">Xorg</span> in any
          prefix other than <code class="filename">/usr</code>, any
          <span class="application">X</span> fonts were not installed in a
          location known to <span class="application">Fontconfig</span>.
          Symlinks were created from the <code class="filename">OTF</code>
          and <code class="filename">TTF</code> <span class=
          "application">X</span> font directories to <code class=
          "filename">/usr/share/fonts/X11-{OTF,TTF}</code>. This allows
          <span class="application">Fontconfig</span> to use the OpenType and
          TrueType fonts provided by <span class="application">X</span>,
          although many people will prefer to use more modern fonts.
        </p>
        <p>
          <span class="application">Fontconfig</span> uses names to define
          fonts. Applications generally use generic font names such as
          "Monospace", "Sans" and "Serif". <span class=
          "application">Fontconfig</span> resolves these names to a font that
          has all characters that cover the orthography of the language
          indicated by the locale settings.
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="useful-commands" name="useful-commands"></a>Useful Commands
        </h2>
        <p>
          The following commands may be helpful when working with fontconfig:
        </p>
        <p>
          <span class="command"><strong>fc-list | less</strong></span> : show
          a list of all available fonts (/path/to/filename: Font Name:style).
          If you installed a font more than 30 seconds ago but it does not
          show, then it or one of its directories is not readable by your
          user.
        </p>
        <p>
          <span class="command"><strong>fc-match 'Font Name'</strong></span>
          : will tell you which font will be used if the named font is
          requested. Typically you would use this to see what happens if a
          font you have not installed is requested, but you can also use it
          if the system is giving you a different font from what you expected
          (perhaps because <span class="application">fontconfig</span> does
          not agree that the font supports your language).
        </p>
        <p>
          <span class="command"><strong>fc-match -a 'Type' |
          less</strong></span> : will provide a list of all fonts which can
          be used for that type (Monospace, Sans, Serif). Note that
          in-extremis <span class="application">fontconfig</span> will take a
          glyph from any available font, even if it is not of the specified
          type, and unless it knows about the font's type it will assume it
          is Sans.
        </p>
        <p>
          If you wish to know which font will be used for a string of text
          (i.e. one or more glyphs, preceded by a space), paste the following
          command and replace the <code class="literal">xyz</code> by the
          text you care about:
        </p>
        <p>
          <span class="command"><strong>FC_DEBUG=4 pango-view
          --font=monospace -t xyz | grep family</strong></span> : this
          requires <a class="xref" href="pango.html" title=
          "Pango-1.44.7">Pango-1.44.7</a> and <a class="xref" href=
          "../general/imagemagick.html" title=
          "ImageMagick-7.0.9-23">ImageMagick-7.0.9-23</a> - it will invoke
          <a class="xref" href=
          "../general/imagemagick.html#display"><span class=
          "command"><strong>display</strong></span></a> to show the text in a
          tiny window, and after closing that the last line of the output
          will show which font was chosen. This is particularly useful for
          CJK languages, and you can also pass a language, e.g.
          PANGO_LANGUAGE=en;ja (English, then assume Japanese) or just zh-cn
          (or other variants - 'zh' on its own is not valid).
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="the-various-files" name="the-various-files"></a>The various
          files
        </h2>
        <p>
          The main files are in <code class=
          "filename">/etc/fonts/conf.d/</code>, which was intended to be a
          directory populated by symlinks to some of the files in
          <code class="filename">/usr/share/fontconfig/conf.avail/</code>.
          But many people, and some packages, create the files directly. Each
          file name must be in the form of two digits, a dash, somename.conf
          and they are read in sequence.
        </p>
        <p>
          By convention, the numbers are assigned as follows:
        </p>
        <div class="itemizedlist">
          <ul>
            <li class="listitem">
              <p>
                00-09 extra font directories
              </p>
            </li>
            <li class="listitem">
              <p>
                10-19 system rendering defaults (antialising etc)
              </p>
            </li>
            <li class="listitem">
              <p>
                20-29 font rendering options
              </p>
            </li>
            <li class="listitem">
              <p>
                30-39 family substitution
              </p>
            </li>
            <li class="listitem">
              <p>
                40-49 map family to generic type
              </p>
            </li>
            <li class="listitem">
              <p>
                50-59 load alternate config files
              </p>
            </li>
            <li class="listitem">
              <p>
                60-69 generic aliases, map generic to family
              </p>
            </li>
            <li class="listitem">
              <p>
                70-79 adjust which fonts are available
              </p>
            </li>
            <li class="listitem">
              <p>
                80-89 match target scan (modify scanned patterns)
              </p>
            </li>
            <li class="listitem">
              <p>
                90-99 font synthesis
              </p>
            </li>
          </ul>
        </div>
        <p>
          You can also have a personal <code class=
          "filename">fonts.conf</code> in $XDG_CONFIG_HOME which is
          <code class="filename">~/.config/fontconfig/</code>.
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="rules-to-choose-a-font" name=
          "rules-to-choose-a-font"></a>The rules to choose a font
        </h2>
        <p>
          If the requested font is installed, and provided it contains the
          codepoints <span class="emphasis"><em>required</em></span> for the
          current language (in the source, see the .orth files in the
          <code class="filename">fc-lang/</code> directory), it will be used.
        </p>
        <p>
          But if the document or page requested a font which is not installed
          (or, occasionally, does not contain all the required codepoints)
          the following rules come into play: First, <code class=
          "filename">30-metric-aliases.conf</code> is used to map aliases for
          some fonts with the same metrics (same size, etc). After that, an
          unknown font will be searched for in <code class=
          "filename">45-latin.conf</code> - if it is found it will be mapped
          as Serif or Monospace or Sans, otherwise it will be assumed to be
          Sans. Then <code class="filename">50-latin.conf</code> provides
          ordered lists of the fallbacks - <a class="xref" href=
          "TTF-and-OTF-fonts.html#dejavu-fonts" title="DejaVu fonts">Dejavu
          fonts</a> will be used if you installed them. Cyrillic and Greek
          appear to be treated in the same way. There are similar files with
          a 65- prefix for Persian and other non-latin writing systems. All
          of these files prefer commercial fonts if they are present,
          although modern libre fonts are often at least their equals.
        </p>
        <p>
          Since fontconfig-2.12.5 there is also generic family matching for
          some emoji and math fonts, see {45,60}-generic.conf.
        </p>
        <p>
          In the rare cases where a font does not contain all the expected
          codepoints, see 'Trial the First:' at <a class="xref" href=
          "tuning-fontconfig.html#I-stared-into-the-fontconfig" title=
          "I stared into the fontconfig ...">I stared into the fontconfig</a>
          for the long details.
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="hinting-and-antialising" name=
          "hinting-and-antialising"></a>Hinting and Anti-aliasing
        </h2>
        <p>
          It is possible to change how, or if, fonts are hinted. The
          following example file contains the default settings, but with
          comments. The settings are very much down to the user's preferences
          and to the choice of fonts, so a change which improves some pages
          may worsen others. The preferred location for this file is:
          <code class="filename">~/.config/fontconfig/fonts.conf</code>
        </p>
        <p>
          To try out different settings, you may need to exit from Xorg and
          then rerun <span class="command"><strong>startx</strong></span> so
          that all applications use the new settings. And if you use Gnome or
          KDE their desktops can override these changes. To explore the
          possibilities, create a file for your user:
        </p>
        <pre class="userinput">
<kbd class="command">mkdir -pv ~/.config/fontconfig &amp;&amp;
cat &gt; ~/.config/fontconfig/fonts.conf &lt;&lt; "EOF"
<code class="literal">&lt;?xml version='1.0'?&gt;
&lt;!DOCTYPE fontconfig SYSTEM 'fonts.dtd'&gt;
&lt;fontconfig&gt;

  &lt;match target="font" &gt;
    &lt;!-- autohint was the old automatic hinter when hinting was patent
    protected, so turn it off to ensure any hinting information in the font
    itself is used, this is the default --&gt;
    &lt;edit mode="assign" name="autohint"&gt;  &lt;bool&gt;false&lt;/bool&gt;&lt;/edit&gt;

    &lt;!-- hinting is enabled by default --&gt;
    &lt;edit mode="assign" name="hinting"&gt;   &lt;bool&gt;true&lt;/bool&gt;&lt;/edit&gt;
    
    &lt;!-- for the lcdfilter see http://www.spasche.net/files/lcdfiltering/ --&gt;
    &lt;edit mode="assign" name="lcdfilter"&gt; &lt;const&gt;lcddefault&lt;/const&gt;&lt;/edit&gt;
    
    &lt;!-- options for hintstyle:
    hintfull: is supposed to give a crisp font that aligns well to the
    character-cell grid but at the cost of its proper shape.

    hintmedium: poorly documented, maybe a synonym for hintfull.
    hintslight is the default: - supposed to be more fuzzy but retains shape.
    
    hintnone: seems to turn hinting off.
    The variations are marginal and results vary with different fonts --&gt;
    &lt;edit mode="assign" name="hintstyle"&gt; &lt;const&gt;hintslight&lt;/const&gt;&lt;/edit&gt;
    
    &lt;!-- antialiasing is on by default and really helps for faint characters
    and also for 'xft:' fonts used in rxvt-unicode --&gt;
    &lt;edit mode="assign" name="antialias"&gt; &lt;bool&gt;true&lt;/bool&gt;&lt;/edit&gt;
    
    &lt;!-- subpixels are usually rgb, see
    http://www.lagom.nl/lcd-test/subpixel.php --&gt;
    &lt;edit mode="assign" name="rgba"&gt;      &lt;const&gt;rgb&lt;/const&gt;&lt;/edit&gt;
    
    &lt;!-- thanks to the Arch wiki for the lcd and subpixel links --&gt;
  &lt;/match&gt;

&lt;/fontconfig&gt;</code>
EOF</kbd>
</pre>
        <p>
          You will now need to edit the file in your preferred editor.
        </p>
        <p>
          For more examples see the blfs-support thread which started at
          <a class="ulink" href=
          "http://lists.linuxfromscratch.org/pipermail/blfs-support/2016-September/078422.html">
          /2016-September/078422</a>, particularly <a class="ulink" href=
          "http://lists.linuxfromscratch.org/pipermail/blfs-support/2016-September/078425.html">
          2016-September/078425</a>, and the original poster's preferred
          solution at <a class="ulink" href=
          "http://lists.linuxfromscratch.org/pipermail/blfs-support/2016-November/078658.html">
          2016-November/078658</a>. There are other examples in <a class=
          "xref" href="tuning-fontconfig.html#arch-fontconfig" title=
          "Fontconfig in the Arch wiki">Fontconfig in the Arch wiki</a> and
          <a class="xref" href="tuning-fontconfig.html#gentoo-fontconfig"
          title="Fontconfig in the Gentoo wiki">Fontconfig in the Gentoo
          wiki</a>.
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="disabling-bitmap-fonts" name=
          "disabling-bitmap-fonts"></a>Disabling Bitmap Fonts
        </h2>
        <p>
          In previous versions of BLFS, the ugly old Xorg bitmap fonts were
          installed. Now, many people will not need to install any of them.
          But if for some reason you have installed one or more bitmap fonts,
          you can prevent them being used by <span class=
          "application">fontconfig</span> by creating the following file as
          the <code class="systemitem">root</code> user :
        </p>
        <pre class="root">
<kbd class=
"command">cat &gt; /etc/fonts/conf.d/70-no-bitmaps.conf &lt;&lt; "EOF"
<code class="literal">&lt;?xml version='1.0'?&gt;
&lt;!DOCTYPE fontconfig SYSTEM 'fonts.dtd'&gt;
&lt;fontconfig&gt;
&lt;!-- Reject bitmap fonts --&gt;
 &lt;selectfont&gt;
  &lt;rejectfont&gt;
   &lt;pattern&gt;
     &lt;patelt name="scalable"&gt;&lt;bool&gt;false&lt;/bool&gt;&lt;/patelt&gt;
   &lt;/pattern&gt;
  &lt;/rejectfont&gt;
 &lt;/selectfont&gt;
&lt;/fontconfig&gt;</code>
EOF</kbd>
</pre>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="adding-extra-directories" name=
          "adding-extra-directories"></a>Adding extra font directories
        </h2>
        <p>
          Normally, system fonts and user fonts are installed in directories
          beneath the locations specified in <a class="xref" href=
          "tuning-fontconfig.html#xft-font-protocol" title=
          "The Xft Font Protocol">The Xft Font Protocol</a> and there is no
          obvious reason to put them elsewhere. However, a full BLFS install
          of <a class="xref" href="../pst/texlive.html" title=
          "texlive-20190410-source">texlive-20190410</a> puts many fonts in
          <code class="filename">/opt/texlive/2019/texmf-dist/fonts/</code>
          in the <code class="filename">opentype/</code> and <code class=
          "filename">truetype/</code> subdirectories. Although pulling in all
          of these files may appear useful (it allows you to use them in non
          <span class="application">TeX</span> programs), there are several
          problems with such an approach:
        </p>
        <div class="orderedlist">
          <ol>
            <li class="listitem">
              <p>
                There are hundreds of files, which makes selecting the font
                hard.
              </p>
            </li>
            <li class="listitem">
              <p>
                Some of the files do odd things, such as displaying semaphore
                flags instead of ASCII letters, or mapping cyrillic
                codepoints to character forms appropriate to Old Church
                Slavonic instead of the expected current shapes: fine if that
                is what you need, but painful for normal use.
              </p>
            </li>
            <li class="listitem">
              <p>
                Several fonts have multiple sizes and impenetrable short
                names, which both make selecting the correct font even
                harder.
              </p>
            </li>
            <li class="listitem">
              <p>
                When a font is added to CTAN, it is accompanied by TeX
                packages to use it in the old engines (<span class=
                "application">xelatex</span> does not normally need this),
                and then the version is often frozen whilst the font is
                separately maintained. Some of these fonts such as <a class=
                "xref" href="TTF-and-OTF-fonts.html#dejavu-fonts" title=
                "DejaVu fonts">Dejavu fonts</a> are probably already
                installed on your BLFS system in a newer version, and if you
                have multiple versions of a font it is unclear which one will
                be used by <span class="application">fontconfig</span>.
              </p>
            </li>
          </ol>
        </div>
        <p>
          However, it is sometimes useful to look at these fonts in non-TeX
          applications, if only to see whether you wish to install a current
          version. If you have installed all of <span class=
          "application">texlive</span>, the following example will make one
          of the Arkandis Open Type fonts available to other applications,
          and all three of the ParaType TrueType fonts. Adjust or repeat the
          lines as desired, to either make all the <code class=
          "filename">opentype/</code> or <code class=
          "filename">truetype</code>fonts available, or to select different
          font directories. As the <code class="systemitem">root</code> user:
        </p>
        <pre class="root">
<kbd class=
"command">cat &gt; /etc/fonts/conf.d/09-texlive.conf &lt;&lt; "EOF"
<code class="literal">&lt;?xml version='1.0'?&gt;
&lt;!DOCTYPE fontconfig SYSTEM 'fonts.dtd'&gt;
&lt;fontconfig&gt;
  &lt;dir&gt;/opt/texlive/2019/texmf-dist/fonts/opentype/arkandis/berenisadf&lt;/dir&gt;
  &lt;dir&gt;/opt/texlive/2019/texmf-dist/fonts/truetype/paratype&lt;/dir&gt;
&lt;/fontconfig&gt;</code>
EOF</kbd>
</pre>
        <p>
          If you do this, remember to change all instances of the year in
          that file when you upgrade <span class="application">texlive</span>
          to a later release.
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="preferring-certain-fonts" name=
          "preferring-certain-fonts"></a>Preferring certain fonts
        </h2>
        <p>
          There are many reasons why people may wish to have pages which
          specify a particular font use a different font, or prefer specific
          fonts in Monospace or Sans or Serif. As you will expect, there a
          number of different ways of achieving this.
        </p>
        <h3>
          <a id="fontconfig-user-docs" name=
          "fontconfig-user-docs"></a>Fontconfig user docs
        </h3>
        <p>
          <span class="application">Fontconfig</span> installs user
          documentation that includes an example 'User configuration file'
          which among other things prefers <a class="xref" href=
          "TTF-and-OTF-fonts.html#wenquanyi-zenhei" title=
          "WenQuanYi Zen Hei">WenQuanYi ZenHei</a> (a Sans font) if a
          <span class="emphasis"><em>Serif</em></span> font is requested for
          Chinese (this part might be anachronistic unless you have non-free
          Chinese fonts, because in <code class=
          "filename">65-nonlatin.conf</code> this font is already among the
          preferred fonts when Serif is specified for Chinese) and to prefer
          the modern <a class="xref" href="TTF-and-OTF-fonts.html#VLGothic"
          title="VL Gothic">VL Gothic</a> font if a Sans font is specified on
          a Japanese page (otherwise a couple of other fonts would be
          preferred if they have been installed).
        </p>
        <p>
          If you have installed the current version, the user documentation
          is available in html, PDF and text versions at <code class=
          "filename">/usr/share/doc/fontconfig-2.13.1/</code> : change the
          version if you installed a different one.
        </p>
        <h3>
          <a id="prefer-a-specific-font" name=
          "prefer-a-specific-font"></a>Prefer a specific font
        </h3>
        <p>
          As an example, if for some reason you wished to use the <a class=
          "ulink" href=
          "https://www.fontsquirrel.com/fonts/nimbus-roman-no9-l">Nimbus
          Roman No9 L</a> font wherever Times New Roman is referenced (it is
          metrically similar, and preferred for Times Roman, but the Serif
          font from <a class="xref" href=
          "TTF-and-OTF-fonts.html#liberation-fonts" title=
          "Liberation fonts">Liberation fonts</a> will be preferred for the
          Times <span class="emphasis"><em>New</em></span> Roman font if
          installed), as an individual user you could install the font and
          then create the following file:
        </p>
        <pre class="userinput">
<kbd class="command">mkdir -pv ~/.config/fontconfig/conf.d &amp;&amp;
cat &gt;  ~/.config/fontconfig/conf.d/35-prefer-nimbus-for-timesnew.conf &lt;&lt; "EOF"
<code class="literal">&lt;?xml version='1.0'?&gt;
&lt;!DOCTYPE fontconfig SYSTEM 'fonts.dtd'&gt;
&lt;fontconfig&gt;
&lt;!-- prefer Nimbus Roman No9 L for Times New Roman as well as for Times,
 without this Tinos and Liberation Serif take precedence for Times New Roman
 before fontconfig falls back to whatever matches Times --&gt;
    &lt;alias binding="same"&gt;
        &lt;family&gt;Times New Roman&lt;/family&gt;
        &lt;accept&gt;
            &lt;family&gt;Nimbus Roman No9 L&lt;/family&gt;
        &lt;/accept&gt;
    &lt;/alias&gt;
&lt;/fontconfig&gt;</code>
EOF</kbd>
</pre>
        <p>
          This is something you would normally do in an individual user's
          settings, but the file in this case has been prefixed '35-' so that
          it could, if desired, be used system-wide in <code class=
          "filename">/etc/fonts/conf.d/</code>.
        </p>
        <h3>
          <a id="prefer-chosen-CJK-fonts" name=
          "prefer-chosen-CJK-fonts"></a>Prefer chosen CJK fonts
        </h3>
        <p>
          The following example of a local configuration (i.e. one that
          applies for all users of the machine) does several things:
        </p>
        <div class="orderedlist">
          <ol>
            <li class="listitem">
              <p>
                If a Serif font is specified, it will prefer the <a class=
                "xref" href="TTF-and-OTF-fonts.html#UMing" title=
                "UMing">UMing</a> variants, so that in the zh-cn, zh-hk and
                zh-tw languages things should look good (also zh-sg which
                actually uses the same settings as zh-cn) <span class=
                "emphasis"><em>without</em></span> affecting Japanese.
              </p>
            </li>
            <li class="listitem">
              <p>
                It prefers the Japanese <a class="xref" href=
                "TTF-and-OTF-fonts.html#IPAex" title="IPAex fonts">IPAex
                fonts</a> if they have been installed (although <a class=
                "xref" href="TTF-and-OTF-fonts.html#VLGothic" title=
                "VL Gothic">VL Gothic</a> will take precedence for (Japanese)
                Sans if it has also been installed.
              </p>
            </li>
            <li class="listitem">
              <p>
                Because <a class="xref" href=
                "TTF-and-OTF-fonts.html#wenquanyi-zenhei" title=
                "WenQuanYi Zen Hei">WenQuanYi ZenHei</a> covers Korean Hangul
                glyphs and is also preferred for Serif in <code class=
                "filename">65-nonlatin.conf</code>, if installed it will be
                used by default for Korean Serif. To get a proper Serif font,
                the UnBatang font is specified here - change that line if you
                installed a different Serif font from the choice of <a class=
                "xref" href="TTF-and-OTF-fonts.html#Korean-fonts" title=
                "Korean fonts:">Korean fonts</a>.
              </p>
            </li>
            <li class="listitem">
              <p>
                The Monospace fonts are forced to the preferred Sans fonts.
                If the text is in Korean then <a class="xref" href=
                "TTF-and-OTF-fonts.html#wenquanyi-zenhei" title=
                "WenQuanYi Zen Hei">WenQuanYi ZenHei</a> will be used.
              </p>
            </li>
          </ol>
        </div>
        <p>
          In a non-CJK locale, the result is that suitable fonts will be used
          for all variants of Chinese, Japanese and Hangul Korean. All other
          languages should already work if a font is present. As the
          <code class="systemitem">root</code> user:
        </p>
        <pre class="root">
<kbd class="command">cat &gt; /etc/fonts/local.conf &lt;&lt; "EOF"
<code class="literal">&lt;?xml version='1.0'?&gt;
&lt;!DOCTYPE fontconfig SYSTEM 'fonts.dtd'&gt;
&lt;fontconfig&gt;
    &lt;alias&gt;
        &lt;family&gt;serif&lt;/family&gt;
        &lt;prefer&gt;
            &lt;family&gt;AR PL UMing&lt;/family&gt;
            &lt;family&gt;IPAexMincho&lt;/family&gt;
            &lt;!-- WenQuanYi is preferred as Serif in 65-nonlatin.conf,
            override that so a real Korean font can be used for Serif --&gt;
            &lt;family&gt;UnBatang&lt;/family&gt;
        &lt;/prefer&gt;
    &lt;/alias&gt;
    &lt;alias&gt;
         &lt;family&gt;sans-serif&lt;/family&gt;
         &lt;prefer&gt;
             &lt;family&gt;WenQuanYi Zen Hei&lt;/family&gt;
             &lt;family&gt;VL Gothic&lt;/family&gt;
             &lt;family&gt;IPAexGothic&lt;/family&gt;
         &lt;/prefer&gt;
    &lt;/alias&gt;
    &lt;alias&gt;
         &lt;family&gt;monospace&lt;/family&gt;
         &lt;prefer&gt;
             &lt;family&gt;VL Gothic&lt;/family&gt;
             &lt;family&gt;IPAexGothic&lt;/family&gt;
             &lt;family&gt;WenQuanYi Zen Hei&lt;/family&gt;
         &lt;/prefer&gt;
    &lt;/alias&gt;
&lt;/fontconfig&gt;</code>
EOF</kbd>
</pre>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="editing-old-style-conf-files" name=
          "editing-old-style-conf-files"></a>Editing Old-style conf files
        </h2>
        <p>
          Some fonts, particularly Chinese fonts, ship with conf files which
          can be installed in <code class=
          "filename">/etc/fonts/conf.d</code>. However, if you do that and
          then use a terminal to run any command which uses <span class=
          "application">fontconfig</span> you may see error messages such as
          :
        </p>
        <p>
          <code class="literal">Fontconfig warning:
          "/etc/fonts/conf.d/69-odofonts.conf", line 14: Having multiple
          &lt;family&gt; in &lt;alias&gt; isn't supported and may not work as
          expected</code>.
        </p>
        <p>
          In practice, these old rules do not work. For non-CJK users,
          <span class="application">fontconfig</span> will usually do a good
          job <span class="emphasis"><em>without</em></span> these rules.
          Their origin dates back to when CJK users needed handcrafted
          bitmaps to be legible at small sizes, and those looked ugly next to
          antialiased Latin glyphs - they preferred to use the same CJK font
          for the Latin glyphs. There is a side-effect of doing this : the
          (Serif) font is often also used for Sans, and in such a situation
          the (English) text in <span class="application">Gtk</span> menus
          will use this font - compared to system fonts, as well as being
          serif it is both faint and rather small. That can make it
          uncomfortable to read.
        </p>
        <p>
          Nevertheless, these old conf files can be fixed if you wish to use
          them. The following example is the first part of <code class=
          "filename">64-arphic-uming.conf</code> from <a class="xref" href=
          "TTF-and-OTF-fonts.html#UMing" title="UMing">UMing</a> - there are
          a lot more similar items which also need changing :
        </p>
        <div class="literallayout">
          <p>
            <br />
            &nbsp;&nbsp;&nbsp;&lt;match&nbsp;target="pattern"&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;test&nbsp;qual="any"&nbsp;name="lang"&nbsp;compare="contains"&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;zh-cn&lt;/string&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;zh-sg&lt;/string&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/test&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;test&nbsp;qual="any"&nbsp;name="family"&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;serif&lt;/string&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/test&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;edit&nbsp;name="family"&nbsp;mode="prepend"&nbsp;binding="strong"&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;AR&nbsp;PL&nbsp;UMing&nbsp;CN&lt;/string&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/edit&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&lt;/match&gt;
          </p>
        </div>
        <p>
          The process to correct this is straightforward but tedious - for
          every item which produces an error message, using your editor (as
          the <code class="systemitem">root</code> user) edit the installed
          file to repeat the whole block as many times as there are multiple
          variables, then reduce each example to have only one of them. You
          may wish to work on one error at a time, save the file after each
          fix, and from a separate term run a command such as <span class=
          "command"><strong>fc-list 2&gt;&amp;1 | less</strong></span> to see
          that the fix worked. For the block above, the fixed version will be
          :
        </p>
        <div class="literallayout">
          <p>
            <br />
            &nbsp;&nbsp;&nbsp;&lt;match&nbsp;target="pattern"&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;test&nbsp;qual="any"&nbsp;name="lang"&nbsp;compare="contains"&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;zh-cn&lt;/string&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/test&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;test&nbsp;qual="any"&nbsp;name="family"&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;serif&lt;/string&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/test&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;edit&nbsp;name="family"&nbsp;mode="prepend"&nbsp;binding="strong"&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;AR&nbsp;PL&nbsp;UMing&nbsp;CN&lt;/string&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/edit&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&lt;/match&gt;<br />
            &nbsp;&nbsp;&nbsp;&lt;match&nbsp;target="pattern"&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;test&nbsp;qual="any"&nbsp;name="lang"&nbsp;compare="contains"&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;zh-sg&lt;/string&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/test&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;test&nbsp;qual="any"&nbsp;name="family"&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;serif&lt;/string&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/test&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;edit&nbsp;name="family"&nbsp;mode="prepend"&nbsp;binding="strong"&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;AR&nbsp;PL&nbsp;UMing&nbsp;CN&lt;/string&gt;<br />

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/edit&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&lt;/match&gt;
          </p>
        </div>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="see-also" name="see-also"></a>See Also
        </h2>
        <h3>
          <a id="I-stared-into-the-fontconfig" name=
          "I-stared-into-the-fontconfig"></a>I stared into the fontconfig ...
        </h3>
        <p>
          The blog entries by <a class="ulink" href=
          "https://eev.ee/blog/2015/05/20/i-stared-into-the-fontconfig-and-the-fontconfig-stared-back-at-me/">
          Eevee</a> are particularly useful if <span class=
          "application">fontconfig</span> does not think your chosen font
          supports your language, and for preferring some non-MS Japanese
          fonts when an ugly MS font is already installed.
        </p>
        <h3>
          <a id="arch-fontconfig" name="arch-fontconfig"></a>Fontconfig in
          the Arch wiki
        </h3>
        <p>
          Arch has a lot of information in its wiki at <a class="ulink" href=
          "https://wiki.archlinux.org/index.php/font_configuration">font_configuration</a>.
        </p>
        <h3>
          <a id="gentoo-fontconfig" name="gentoo-fontconfig"></a>Fontconfig
          in the Gentoo wiki
        </h3>
        <p>
          Gentoo has some information in its wiki at <a class="ulink" href=
          "https://wiki.gentoo.org/wiki/Fontconfig">Fontconfig</a> although a
          lot of the details (what to enable, and Infinality) are specific to
          Gentoo.
        </p>
      </div>
      <p class="updated">
        Last updated on 2020-03-21 06:02:56 -0500
      </p>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="xorg-config.html" title=
          "Xorg-7 Testing and Configuration">Prev</a>
          <p>
            Xorg-7 Testing and Configuration
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="TTF-and-OTF-fonts.html" title=
          "TTF and OTF fonts">Next</a>
          <p>
            TTF and OTF fonts
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="installing.html" title=
          "Chapter&nbsp;24.&nbsp;X Window System Environment">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
  </body>
</html>
